package com.wswy.wzcx.ui.module.lbs

import android.graphics.BitmapFactory
import com.amap.api.maps2d.AMap
import com.amap.api.maps2d.model.BitmapDescriptor
import com.amap.api.maps2d.model.BitmapDescriptorFactory
import com.amap.api.services.core.PoiItem
import com.wswy.wzcx.AppContext
import com.wswy.wzcx.R

class GasPoiOverlay (amap: AMap?, pois:List<PoiItem>? ,val type:Int): PoiOverlay(amap, pois) {


    override fun getBitmapDescriptor(index: Int): BitmapDescriptor? {
        return when(type){

            Lbs.TYPE_CAR_PARK.typeCode -> {
                BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(AppContext.getContext().resources,
                        R.drawable.map_parking))
            }

            Lbs.TYPE_GAS.typeCode -> {
                val drawableRes = when(getPoiItem(index)?.typeCode){
                    "010101" -> R.drawable.map_zhongshihua
                    "010102" -> R.drawable.map_zhongshiyou
                    else -> R.drawable.map_other
                }
                BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(AppContext.getContext().resources,
                        drawableRes))
            }
            Lbs.TYPE_CAR_WASH.typeCode -> {
                BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(AppContext.getContext().resources,
                        R.drawable.map_xiche))
            }
            Lbs.TYPE_CAR_4S.typeCode -> {
                BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(AppContext.getContext().resources,
                        R.drawable.map_4s))
            }
            else -> null
        }

    }

}